{include file="public/base" /}
{block name="main"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加权限组</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form method="get" action="javascript:;" class="form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">权限组名字</label>
                            <div class="col-sm-10">
                                <input type="text" name="name"  class="form-control" required>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="mail-body">
                            <h4>用户权限：</h4>
                            <p>
                                {volist name="rules" id="k"}
                                {if $k.classify==1}
                                <label class="checkbox-inline">
                                    <input type="checkbox" value="{$k.id}" name="rulesid[]">{$k.name}
                                </label>
                                {/if}
                                {/volist}
                            </p>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="mail-body">
                            <h4>明细权限：</h4>
                            <p>
                                {volist name="rules" id="k"}
                                {if $k.classify==2}
                                <label class="checkbox-inline">
                                    <input type="checkbox" value="{$k.id}"  name="rulesid[]">{$k.name}
                                </label>
                                {/if}
                                {/volist}
                            </p>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="mail-body">
                            <h4>买卖单权限：</h4>
                            <p>
                                {volist name="rules" id="k"}
                                {if $k.classify==3}
                                <label class="checkbox-inline">
                                    <input type="checkbox" value="{$k.id}"  name="rulesid[]">{$k.name}
                                </label>
                                {/if}
                                {/volist}
                            </p>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="mail-body">
                            <h4>生活服务权限：</h4>
                            <p>
                                {volist name="rules" id="k"}
                                {if $k.classify==4}
                                <label class="checkbox-inline">
                                    <input type="checkbox" value="{$k.id}"  name="rulesid[]">{$k.name}
                                </label>
                                {/if}
                                {/volist}
                            </p>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="mail-body">
                            <h4>店铺管理权限：</h4>
                            <p>
                                {volist name="rules" id="k"}
                                {if $k.classify==5}
                                <label class="checkbox-inline">
                                    <input type="checkbox" value="{$k.id}"  name="rulesid[]">{$k.name}
                                </label>
                                {/if}
                                {/volist}
                            </p>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="mail-body">
                            <h4>投诉管理权限：</h4>
                            <p>
                                {volist name="rules" id="k"}
                                {if $k.classify==6}
                                <label class="checkbox-inline">
                                    <input type="checkbox" value="{$k.id}"  name="rulesid[]">{$k.name}
                                </label>
                                {/if}
                                {/volist}
                            </p>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="mail-body">
                            <h4>公告管理权限：</h4>
                            <p>
                                {volist name="rules" id="k"}
                                {if $k.classify==7}
                                <label class="checkbox-inline">
                                    <input type="checkbox" value="{$k.id}"  name="rulesid[]">{$k.name}
                                </label>
                                {/if}
                                {/volist}
                            </p>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="mail-body">
                            <h4>开户银行管理权限：</h4>
                            <p>
                                {volist name="rules" id="k"}
                                {if $k.classify==8}
                                <label class="checkbox-inline">
                                    <input type="checkbox" value="{$k.id}"  name="rulesid[]">{$k.name}
                                </label>
                                {/if}
                                {/volist}
                            </p>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="mail-body">
                            <h4>关于我们权限：</h4>
                            <p>
                                {volist name="rules" id="k"}
                                {if $k.classify==9}
                                <label class="checkbox-inline">
                                    <input type="checkbox" value="{$k.id}"  name="rulesid[]">{$k.name}
                                </label>
                                {/if}
                                {/volist}
                            </p>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="mail-body">
                            <h4>设置权限：</h4>
                            <p>
                                {volist name="rules" id="k"}
                                {if $k.classify==10}
                                <label class="checkbox-inline">
                                    <input type="checkbox" value="{$k.id}"  name="rulesid[]">{$k.name}
                                </label>
                                {/if}
                                {/volist}
                            </p>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="submit" onclick="edit()">保存内容</button>
                                <!--<button class="btn btn-white" type="submit">取消</button>-->
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="javascript"}
<script src="ADMIN_JS/content.min.js?v=1.0.0"></script>
<script src="ADMIN_JS/plugins/iCheck/icheck.min.js"></script>
<script>
    function edit()
    {
        var loading = layer.msg('正在提交数据，请稍后...', {icon: 16,time:3000});
        var obj = document.getElementsByName("rulesid[]");
        var check_val = [];
        for(k in obj){
            if(obj[k].checked)
                check_val.push(obj[k].value);
        }
        var name = $("[name='name']").val();
        $.ajax({
            type:'post',
            url:'{:url("group/add")}',
            data:{'rulesid':check_val,'name':name},
            success:function(data){
                layer.close(loading);
                if(data.code==1){
                    layer.msg(data.msg,{icon:6,time:1500});
                    setTimeout(function(){window.parent.location.reload();},1000);
                }else{
                    layer.msg(data.msg,{icon:5,time:1500});
                }
            }
        })
    }

</script>
{/block}